#!/bin/sh

# Created by Robert Carlsen on 15.07.2009.
# build an arm / i386 / x64 lib of standard linux project
#
# adopted from: http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html
#
# copied from: http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
#
# configured for libical
#
# Note:
# To run with the iPhone the assembly just be a Universal binary (FAT) with i386 arch for the simulator
# and arm arch for the iPhone hardware which has the arm processor.

OUTPUTDIR=../libical-build

mkdir -p $OUTPUTDIR/fat

# combine the arch-specific binaries into  a FAT binary
$DEVROOT/usr/bin/lipo \
	-arch arm $OUTPUTDIR/armv6/libical-static.a \
	-arch i386 $OUTPUTDIR/i386/libical-static.a \
	-arch x86_64 $OUTPUTDIR/x86_64/libical-static.a \
	-create -output $OUTPUTDIR/fat/libical-static.a
$DEVROOT/usr/bin/lipo \
	-arch arm $OUTPUTDIR/armv6/libical.a \
	-arch i386 $OUTPUTDIR/i386/libical.a \
	-arch x86_64 $OUTPUTDIR/x86_64/libical.a \
	-create -output $OUTPUTDIR/fat/libical.a
$DEVROOT/usr/bin/lipo \
	-arch arm $OUTPUTDIR/armv6/libicalss.a \
	-arch i386 $OUTPUTDIR/i386/libicalss.a \
	-arch x86_64 $OUTPUTDIR/x86_64/libicalss.a \
	-create -output $OUTPUTDIR/fat/libicalss.a
$DEVROOT/usr/bin/lipo \
	-arch arm $OUTPUTDIR/armv6/libicalvcal.a \
	-arch i386 $OUTPUTDIR/i386/libicalvcal.a \
	-arch x86_64 $OUTPUTDIR/x86_64/libicalvcal.a \
	-create -output $OUTPUTDIR/fat/libicalvcal.a

lipo -info $OUTPUTDIR/fat/*.a

echo "See $OUTPUTDIR"

